import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import Components from 'unplugin-vue-components/vite'
// import { VantResolver } from 'unplugin-vue-components/resolvers'
// import { IoUIResolver } from './dist/resolver/index'
// 打包后的目录
// https://vitejs.dev/config/
export default defineConfig({
  resolve: {                                       // +++
    alias: {
      '@': resolve(__dirname, './src')         // +++
    }                                            // +++
  },
  plugins: [
    vue(),
    Components({
      // 指定组件位置，默认是src/components
      dirs: ['src/packages/components'],
      extensions: ['vue'],
      // 配置文件生成位置
      dts: 'src/components.d.ts',
      // directoryAsNamespace: true,
      // globalNamespaces: ['global'],
      // include: [/\.vue$/, /\.md$/],
      resolvers: [
        // IoUIResolver(),
        // (componentName) => {
        //   console.log('------componentName=', componentName, resolve(__dirname, 'src/packages/index.ts'))
        //   if (componentName.startsWith('Io')) {
        //     return { name: componentName.slice(2), from: resolve(__dirname, 'src/packages/index.ts') }
        //   }
        // }
      ],
    }),
  ],

  //配置打包入口 https://cn.vitejs.dev/guide/build.html#library-mode
  build: {

  },
})
